package com.henghe.frame.mq.config.mqtt;

import com.henghe.frame.mq.annotation.OrderHandlerType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2023/3/31 15:14
 */
@Component
public class HandlerContext {

    @Autowired
    private ApplicationContext beanFactory;

    public AbstractHandler getInstance(String type){
        Map<String,Class> map = (Map<String, Class>) beanFactory.getBean(OrderHandlerType.class.getName());

        return (AbstractHandler) beanFactory.getBean(map.get(type));

    }
}
